<template>
  <div>
    <table>
      <tr>
        <td>名称</td>
        <td>图片</td>
        <td>讲师</td>
      </tr>
      <tr v-for="i in clist">
        <td>{{ i.name }}</td>
        <td>
          <img
            :src="'http://localhost:5000/static/upload/' + i.pic"
            width="100"
            height="100"
          />
        </td>
        <td>{{ i.tname }}</td>
        <router-link :to="{ name: 'put_course', query: { id: i.id } }"
          >修改</router-link
        >
      </tr>
      <tr>
        <td>
          <!-- <van-pagination
            v-model="currentPage"
            :total-items="total"
            :items-per-page="size"
            @change="getlist"
          /> -->
          <button v-for="i in total" @click="getlist(i)">{{i}}</button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      clist: [],
      total: 0,
      size: 3,
      currentPage: 1,
    };
  },
  methods: {
    getlist(p) {
        this.currentPage = p
      this.$axios
        .get("/add_ncourse?cpage=" + p + "&size=" + this.size)
        .then((res) => {
          if (res.data.code == 200) {
            this.clist = res.data.list;
            this.total = res.data.total;
          }
        })
        .catch((err) => {});
    },
  },
  mounted() {
    this.getlist(1);
  },
};
</script>

<style scoped>
</style>